package com.jinghang.Zookeeper.countdown;

import java.util.concurrent.CountDownLatch;

/**
 * 抽象类，用于演示 服务状态监控中心 统一检查
 */
public abstract class CheckCenter implements Runnable {

	private CountDownLatch countDown;		// 计数器
	private String staff;					// 服务（zookeeper，hbase,mysql）
	protected boolean ok;						// 是否检查ok的标志
	
	public CheckCenter(CountDownLatch countDown, String staff) {
		this.countDown = countDown;
		this.staff = staff;
		this.ok = false;
	}

	@Override
	public void run() {
		try {
			check();
		} catch (Exception e) {
			e.printStackTrace();
			ok = false;
		} finally {
			if (countDown != null) {
				//3 2 1 0
				countDown.countDown();
			}
		}
	}

	/**

	 	节点剩余内存空间
	 	节点剩余硬盘空间
	 	启动状态


	 */
	public abstract void check();














	public CountDownLatch getCountDown() {
		return countDown;
	}
	public void setCountDown(CountDownLatch countDown) {
		this.countDown = countDown;
	}
	public String getStaff() {
		return staff;
	}
	public void setStaff(String staff) {
		this.staff = staff;
	}
	public boolean isOk() {
		return ok;
	}
	public void setOk(boolean ok) {
		this.ok = ok;
	}
	
}
